/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qsdm.es.persistence;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "centroformacion", catalog = "qsdm", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Centroformacion.findAll", query = "SELECT c FROM Centroformacion c"),
    @NamedQuery(name = "Centroformacion.findById", query = "SELECT c FROM Centroformacion c WHERE c.id = :id"),
    @NamedQuery(name = "Centroformacion.findByNombre", query = "SELECT c FROM Centroformacion c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Centroformacion.findByCodigo", query = "SELECT c FROM Centroformacion c WHERE c.codigo = :codigo"),
    @NamedQuery(name = "Centroformacion.findByContacto", query = "SELECT c FROM Centroformacion c WHERE c.contacto = :contacto")})
public class Centroformacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "nombre", length = 45)
    private String nombre;
    @Column(name = "codigo", length = 45)
    private String codigo;
    @Column(name = "contacto", length = 45)
    private String contacto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "centroFormacion", fetch = FetchType.LAZY)
    private List<Curso> cursoList;
    @JoinColumn(name = "municipio", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Municipio municipio;

    public Centroformacion() {
    }

    public Centroformacion(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getContacto() {
        return contacto;
    }

    public void setContacto(String contacto) {
        this.contacto = contacto;
    }

    @XmlTransient
    public List<Curso> getCursoList() {
        return cursoList;
    }

    public void setCursoList(List<Curso> cursoList) {
        this.cursoList = cursoList;
    }

    public Municipio getMunicipio() {
        return municipio;
    }

    public void setMunicipio(Municipio municipio) {
        this.municipio = municipio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Centroformacion)) {
            return false;
        }
        Centroformacion other = (Centroformacion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsdm.es.persistence.Centroformacion[ id=" + id + " ]";
    }
    
}
